//
//  YTFEmotion.swift
//  sinaWeibo
//
//  Created by pro on 16/3/9.
//  Copyright © 2016年 pro. All rights reserved.
//

import UIKit


//表情模型类
class YTFEmotion: NSObject {
 /// 发布微博用
    var chs: String?
 /// 图片的名字，用于拼接图片路径
    var png: String?
 /// emoji类型,赋值之后直接转变为可识别的表情文字
    var code: String?{
    
        didSet{
            //1.创建一个scanner对象
            let scan = NSScanner(string: code!)
            
            //2.定义一个可变的UInt32的来接收
            var result: UInt32 = 0
            scan.scanHexInt(&result)
            
            //3.转成一个Unicode
            let unicode = UnicodeScalar(result)
            
            //4.把Unicode转化成character
            let character = Character(unicode)
            
            //赋值给emoji属性
            emoji = "\(character)"
            
        }
    
    }
    /// 定义图片的包路径
    var path: String?
    
    /// emoji
    var emoji: String?
    
    override init() {
        super.init()
    }
    
    init(dict: [String:NSObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    //防止奔溃
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {}
}
